﻿@{
    ViewBag.Title = "AutoMarketingList";
}

@section scripts
{
    <script src="@Url.Content("~/Scripts/shared/share.js")" type="text/javascript"></script> 
    <script src="@Url.Content("~/Scripts/shared/shown.js")" type="text/javascript"></script>     
    <script src="@Url.Content("~/Scripts/common/export.js")" type="text/javascript"></script>
}

       
        @Html.Partial("~/Views/Modular/ToolBarBase.cshtml")

        <table>
            <tr>
                <td width ="70px" align="right">方案名称：</td>
                <td width ="200px">
                    <input name="FNumber" class="mini-textbox" style="width:200px;"  onkeypress="setkeyPress()"/>
                </td>
                <td width ="100px" align="center">
                    <a class="mini-button" iconCls="icon-search" onclick="search" plain="true">查询</a>
                </td>
            </tr>
        </table>
    <div class="mini-fit">
        <div id="datagrid1" class="mini-datagrid" style="width:100%;height:100%;" pageSize="15"
                borderStyle="border:1;" url="../Member/GetMarketingList"
                allowCellSelect="true" allowCellEdit="true"showColumnsMenu="true"fitColumns="false"  
                onrowdblclick="modify"  sortMode="client">
            <div property="columns">
                <div type="checkcolumn" >选行</div>
                <div type="indexcolumn" width="40" headerAlign="center" >序号</div>
                <div field="FTypeName" name="FTypeName" width="100" headeralign="center" allowsort="true">方案类型</div>
                <div field="FName" name="FName" width="230" headeralign="center" allowsort="true">方案名称</div>
                <div field="FInactiveDays" name="FInactiveDays" width="70" headeralign="center" align="right" allowsort="true">天数</div>
                <div field="FStartDate" name="FStartDate" width="80" headeralign="center" allowsort="true">开始日期</div>
                <div field="FEndDate" name="FEndDate" width="80" headeralign="center" allowsort="true">结束日期</div>
                <div field="FStartTime" name="FStartTime" width="80" headeralign="center" align="right" allowsort="true">发送时间</div>
                <div field="FStateName" name="FStateName" width="100" headeralign="center" align="center" allowsort="true">是否启用</div>
                <div field="FSendSMSName" name="FSendSMSName" width="100" headeralign="center" align="center" allowsort="true">是否短信</div>
                <div field="FCouponName" name="FCouponName" width="150" headeralign="center" allowsort="true">优惠券</div>
            </div>
        </div>
    </div>
<script>
    mini.parse();
    var grid = mini.get("datagrid1");

    function FormShown() {        
        LoadListData();
    }
    function setkeyPress() {
        LoadListData();
    }

    //加载资料列表
    function LoadListData() {
        var mNumber = mini.getbyName("FNumber").getValue();

        var sSystemAppID = parent.window.getSystemAppID();
            var json = "[{";
            json = json + '"mSystemAppID":' + '"' + sSystemAppID + '",';
            json = json + '"mNumber":' + '"' + mNumber + '"';
            json = json + "}]";
            grid.load({ mydata: json });
    }

    //搜索资料列表
    function search() {
        LoadListData();
    }
    //刷新
    function refresh() {
        mini.getbyName("FNumber").setValue('');
        LoadListData();
    }

    ///增加资料
    function newBill() {
        var uID = parent.window.getSystemAppID();
        mini.open({
            url: "/Member/automarketing",
            title: "自动营销方案", width: 600, height: 500,
            onload: function () {
                var iframe = this.getIFrameEl();
                var data = { action: "new", FItemID: 0 };
                iframe.contentWindow.SetData(data);
            },
            ondestroy: function (action) {
                grid.reload();
            }
        });
    }

    //修改资料
    function modify() {
        var row = grid.getSelected();
        if (row) {
            mini.open({
                url: "/member/automarketing",
                title: "自动营销方案", width: 600, height: 500,
                onload: function () {
                    var iframe = this.getIFrameEl();
                    var data = { action: "edit", FItemID: row.FItemID };
                    iframe.contentWindow.SetData(data);
                },
                ondestroy: function (action) {
                    LoadListData();
                }
            });

        } else {
            mini.alert("请选中一条记录");
        }
    }

    //删除资料
    function removeInfo() {
        var row = grid.getSelected();
        var FSystemAppID = parent.window.getSystemAppID();
        if (row) {
            mini.confirm("确定要删除选中的记录吗？", "提示",
                function (action) {
                    if (action == "ok") {
                        var json = "{'FItemID':'" + row.FItemID + "'}";
                        $.post("RemoveMarketing", { json: json, mSystemAppID: FSystemAppID }, function (data) {
                            var ret = mini.decode(data);
                            if (ret.status == 1) {
                                mini.showTips({ content: ret.msg, state: "success", x: "center", y: "top", timeout: 3000 });
                                grid.reload();
                            }
                            else {
                                mini.alert("" + ret.error);
                            }
                        });
                    }
                });
        } else {
            mini.alert("请选中一条记录");
        }
    }

</script>
